﻿<?xml version="1.0" encoding="utf-8"?>
<Recipe Name="CreateBEfromDBCommon">
  <Arguments xmlns="http://schemas.microsoft.com/pag/gax-core" xmlns:xi="http://www.w3.org/2001/XInclude">
    <xi:include href="../Common/CommonArguments.xml" xpointer="xmlns(gax=http://schemas.microsoft.com/pag/gax-core) xpointer(/gax:Arguments/gax:Argument)" />

    <Argument Name="CurrentProject" Type="EnvDTE.Project, EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
      <Converter Type="ProjectConverter" />
      <ValueProvider Type="Microsoft.Practices.RecipeFramework.Library.Solution.ValueProviders.CurrentProjectProvider, Microsoft.Practices.RecipeFramework.Library" />
    </Argument>
    
    <Argument Name="BusinessEntitiesProject" Type="EnvDTE.Project, EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
      <Converter Type="Microsoft.Practices.RepositoryFactory.Converters.ProjectWithResponsibilityConverter, Microsoft.Practices.RepositoryFactory" ResponsibilityArgument="IsBusinessEntityProject" />
      <ValueProvider Type="Microsoft.Practices.RepositoryFactory.ValueProviders.ProjectsWithResponsibilityProvider, Microsoft.Practices.RepositoryFactory" ResponsibilityArgument="IsBusinessEntityProject" CurrentProjectArgument="CurrentProject" />
    </Argument>

    <Argument Name="BusinessEntitiesProjectFolder" Type="EnvDTE.ProjectItem, EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
      <Converter Type="Microsoft.Practices.RepositoryFactory.Converters.ProjectFolderConverter, Microsoft.Practices.RepositoryFactory"
                 ProjectArgument="BusinessEntitiesProject"/>
      <!--<Converter Type="Microsoft.Practices.RecipeFramework.Library.Converters.ProjectItemConverter, Microsoft.Practices.RecipeFramework.Library" />-->
      <ValueProvider Type="Microsoft.Practices.RepositoryFactory.ValueProviders.ProjectFoldersProvider, Microsoft.Practices.RepositoryFactory"
             ProjectArgument="BusinessEntitiesProject"/>
    </Argument>

    <Argument Name="BusinessEntityClassNamespace">
      <ValueProvider Type="Evaluator" Expression="$(BusinessEntitiesProject.Properties.Item('DefaultNamespace').Value.ToString()).BusinessEntities">
        <MonitorArgument Name="BusinessEntitiesProject"/>
      </ValueProvider>
    </Argument>


    <Argument Name="ParentNamespace">
      <Converter Type="Microsoft.Practices.RecipeFramework.Library.Converters.NamespaceStringConverter, Microsoft.Practices.RecipeFramework.Library"/>
      <ValueProvider Type="Evaluator"
      Expression="$(BusinessEntitiesProject.Properties.Item('DefaultNamespace').Value)" />
    </Argument>

    <Argument Name="TemplatePath">
      <ValueProvider Type="Evaluator"
        Expression="T4\BE.$(RecipeLanguage)\BusinessEntity.$(RecipeLanguage).t4"/>
    </Argument>

    <Argument Name="ConnectionSettingProviderArg" Required="false">
      <ValueProvider Type="Evaluator"
        Expression="$(ConnectionSettings.ProviderName)">
        <MonitorArgument Name="ConnectionSettings"/>
      </ValueProvider>
    </Argument>

    <Argument Name="TablesTreeView" Type="System.Windows.Forms.TreeView, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    <Argument Name="Tables" Type="System.Collections.ArrayList, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    <Argument Name="Entities" Type="System.Collections.ArrayList, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    
    <xi:include href="../Common/CommonConnectionStringWizardPages.xml" xpointer="xmlns(gax=http://schemas.microsoft.com/pag/gax-core) xpointer(/gax:Recipe/gax:Arguments/gax:Argument)" />
  </Arguments>

  <GatheringServiceData>
    <Wizard xmlns="http://schemas.microsoft.com/pag/gax-wizards" SchemaVersion="1.0" Help="ms-help://MS.VSCC.v80/MS.VSIPCC.v80/ms.wssf.2006Dec/WSSF/html/10-070-Create_Business_Entities_from_a_Database.htm">
      <Pages xmlns:xi="http://www.w3.org/2001/XInclude">
        <xi:include href="../Common/CommonConnectionStringWizardPages.xml" xpointer="xmlns(gax=http://schemas.microsoft.com/pag/gax-core) xmlns(gaxw=http://schemas.microsoft.com/pag/gax-wizards) xpointer(/gax:Recipe/gax:GatheringServiceData/gaxw:Wizard/gaxw:Pages/gaxw:Page)" />
        <Page>
          <Title>Namespace Selection</Title>
          <LinkTitle>Namespace Selection</LinkTitle>
          <Help>Determine the project folder where Business Entities will be created. Defaults to BusinessEntities</Help>
          <Fields>
            <Field Label="Business Entities Namespace" ValueName="BusinessEntityClassNamespace">
              <Tooltip>Business Entities Namespace</Tooltip>
            </Field>
            <!--
            <Field Label="Business Entities Folder" ValueName="BusinessEntitiesProjectFolder">
              <Tooltip>Business Entities Folder</Tooltip>
            </Field>
            -->
          </Fields>
        </Page>
        <Page Type="Microsoft.Practices.RepositoryFactory.CustomPages.EntitiesTablesSelectorCP, Microsoft.Practices.RepositoryFactory"  Height="440" Width="550">
          <Title>Data tables properties</Title>
          <LinkTitle>Specify Tables</LinkTitle>
          <Help>Specify the tables that you want to create the business entities from.</Help>
        </Page>
        <Page Type="Microsoft.Practices.RepositoryFactory.CustomPages.EntitiesSelectorCP, Microsoft.Practices.RepositoryFactory">
          <Title>Business entities properties</Title>
          <LinkTitle>Customize business entities</LinkTitle>
          <Help>Customize the business entities that you want to create.</Help>
        </Page>
      </Pages>
    </Wizard>
  </GatheringServiceData>
  <Actions xmlns="http://schemas.microsoft.com/pag/gax-core">
    <Action Name="GenerateBusinessEntities" Type="Microsoft.Practices.RecipeFramework.VisualStudio.Library.Templates.TextTemplateAction, Microsoft.Practices.RecipeFramework.VisualStudio.Library">
      <Input Name="ParentNamespace" RecipeArgument="ParentNamespace"/>
      <Input Name="Template" RecipeArgument="TemplatePath"/>
      <Input Name="Entities" RecipeArgument="Entities" />
      <Input Name="BusinessEntityClassNamespace" RecipeArgument="BusinessEntityClassNamespace" />
      <Input Name="ConnectionSettingProvider" RecipeArgument="ConnectionSettingProviderArg"/>
      <Output Name="Content" />
    </Action>
    <Action Name="AddEntities" Type="Microsoft.Practices.RepositoryFactory.Actions.VisualStudio.SplitAndAddItemsFromStringAction, Microsoft.Practices.RepositoryFactory" Open="true" Overwrite="true" ShowConfirmation="true">
      <Input Name="Content" ActionOutput="GenerateBusinessEntities.Content" />
      <Input Name="Project" RecipeArgument="BusinessEntitiesProject" />
      <Input Name="RecipeLanguage" RecipeArgument="RecipeLanguage"/>
    </Action>
  </Actions>
</Recipe>